﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.Framework.Communication.Messages;

namespace PSE.Framework.Communication.Adapters
{
    /// <summary>
    /// Exceção que contém informações sobre a mensagem
    /// </summary>
    public class AdapterMessageException : AdapterException
    {
                /// <summary>
        /// Construtor padrão
        /// </summary>
        public AdapterMessageException()
            : base()
        { 
        }

        /// <summary>
        /// Construtor que preenche Message, Process, AdapterDirection e CommunicationMessage
        /// </summary>
        /// <param name="message">Mensagem de erro</param>
        /// <param name="process">Nome do processo</param>
        /// <param name="adapterDirection">Direção do adapter</param>
        /// <param name="communicationMessage">Mensagem com erro</param>
        public AdapterMessageException(string message, string process, AdapterDirection adapterDirection, object communicationMessage)
            : base(message, process, adapterDirection)
        {
            if (communicationMessage == null)
                throw new ArgumentNullException("communicationMessage");

            _communicationMessage = communicationMessage;
        }

        /// <summary>
        /// Construtor que preenche Message, Process, AdapterDirection, CommunicationMessage e InnerException
        /// </summary>
        /// <param name="message">Mensagem de erro</param>
        /// <param name="process">Nome do processo</param>
        /// <param name="adapterDirection">Direção do adapter</param>
        /// <param name="communicationMessage">Mensagem com erro</param>
        /// <param name="innerException">Exception original</param>
        public AdapterMessageException(string message, string process, AdapterDirection adapterDirection, object communicationMessage, Exception innerException)
            : base(message, process, adapterDirection, innerException)
        {
            if (communicationMessage == null)
                throw new ArgumentNullException("communicationMessage");

            _communicationMessage = communicationMessage;
        }

        /// <summary>
        /// Construtor que preenche Message, Process, AdapterDirection, Action e CommunicationMessage
        /// </summary>
        /// <param name="message">Mensagem de erro</param>
        /// <param name="process">Nome do processo</param>
        /// <param name="adapterDirection">Direção do adapter</param>
        /// <param name="action">Action da mensagem</param>
        /// <param name="communicationMessage">Mensagem com erro</param>
        public AdapterMessageException(string message, string process, AdapterDirection adapterDirection, string action, object communicationMessage)
            : this(message, process, adapterDirection, communicationMessage)
        {
            if (string.IsNullOrEmpty(action))
                throw new ArgumentNullException("action");

            _action = action;
        }

        /// <summary>
        /// Construtor que preenche Message, Process, AdapterDirection, Action, CommunicationMessage e InnerException
        /// </summary>
        /// <param name="message">Mensagem de erro</param>
        /// <param name="process">Nome do processo</param>
        /// <param name="adapterDirection">Direção do adapter</param>
        /// <param name="action">Action da mensagem</param>
        /// <param name="communicationMessage">Mensagem com erro</param>
        /// <param name="innerException">Exception original</param>
        public AdapterMessageException(string message, string process, AdapterDirection adapterDirection, string action, object communicationMessage, Exception innerException)
            : this(message, process, adapterDirection, communicationMessage, innerException)
        {
            if (string.IsNullOrEmpty(action))
                throw new ArgumentNullException("action");

            _action = action;
        }

        private string _action = null;
        /// <summary>
        /// Action da mensagem
        /// </summary>
        public string Action
        {
            get { return _action; }
        }

        private object _communicationMessage = null;
        /// <summary>
        /// Mensagem com erro
        /// </summary>
        public object CommunicationMessage
        {
            get { return _communicationMessage; }
        }
    }
}
